package br.com.mmm.javacenter.framework.reflection.injectors;

import org.apache.log4j.Logger;

import br.com.mmm.javacenter.framework.annotations.InjectorComponent;
import br.com.mmm.javacenter.framework.configuration.IocController;
import br.com.mmm.javacenter.framework.dao.HibernateUtil;

public final class InjectorFactory {
	private static Logger logger = Logger.getLogger(InjectorFactory.class);
	
	public static Injector getInjector(Class<?> klass){
		for(Class<?> k:IocController.injectorsBeans){
			Class<?>[] antende = ((InjectorComponent) k.getAnnotation(InjectorComponent.class)).value();
			for(Class<?> k2:antende){
				if(k2 == klass || k2.isAssignableFrom(klass)){
					logger.debug(k.getSimpleName() + " to " + klass.getSimpleName() );
					return (Injector) IocController.picoSetterContainer.getComponentInstanceOfType(k);
				}
			}
		}
		return null;
	}
}
